<template>
	<div>
		<el-dialog title="备注" v-model="dialogVisible" width="600px" @close="dialogFormVisible"
			:close-on-click-modal="false" :close-on-press-escape="false">
			<el-form size="small" ref="form" :model="form">
				<el-form-item label="备注" :label-width="formLabelWidth" prop="remark"
					:rules="[{ required: true, message: ' ' }]">
					<el-input type="textarea" v-model="form.remark" placeholder="请输入备注"></el-input>
				</el-form-item>
			</el-form>
			<template #footer>
				<div class="dialog-footer">
					<el-button @click="dialogFormVisible">取 消</el-button>
					<el-button type="primary" @click="submit" :loading="loading">确 定</el-button>
				</div>
			</template>
		</el-dialog>
	</div>
</template>
<script>
	import {
		remarks
	} from "@/api/lottery.js";
	export default {
		components: {},
		data() {
			return {
				loading: false,
				/*左边长度*/
				formLabelWidth: "120px",
				/*是否显示*/
				dialogVisible: false,
				form: {
					remark: "",
				},
			};
		},
		props: ["is_remark", "Val"],
		created() {
			this.dialogVisible = this.is_remark;
			this.form = this.Val;
		},
		methods: {
			/*处理*/
			submit() {
				let self = this;
				let Params = {};
				Params.remark = self.form.remark;
				Params.record_id = self.Val.record_id;
				self.$refs.form.validate((valid) => {
					if (valid) {
						self.loading = true;
						remarks(Params, true)
							.then((data) => {
								self.loading = false;
								ElMessage({
									message: data.msg,
									type: "success",
								});
								self.dialogFormVisible(true);
							})
							.catch((error) => {
								self.loading = false;
							});
					}
				});
			},
			/*关闭弹窗*/
			dialogFormVisible(e) {
				if (e) {
					this.$emit("closeDialog", {
						type: "success",
						openDialog: false,
					});
				} else {
					this.$emit("closeDialog", {
						type: "error",
						openDialog: false,
					});
				}
			},
		},
	};
</script>
<style></style>